@tool
class_name ContextBehavior_Pursue
extends ContextBehavior_Seek

#region 属性
@export var prediction_t:float = 0.1
#endregion
#region 字段
#endregion
#region 信号
#endregion

#region 基类方法
func init():
	super()
func get_target_pos(target:Node2D) -> Vector2:
	return target.global_position + prediction_t * get_target_vel(target)
func calc_steering(behaviors_owner:Node,agent:SteeringBehaviorAgent,delta:float):
	super(behaviors_owner,agent,delta)
#endregion
#region 公共方法
func get_target_vel(target:Node2D) -> Vector2:
	if target is CharacterBody2D:
		return target.velocity
	elif target is RigidBody2D:
		return target.linear_velocity
	return Vector2.ZERO
#endregion
#region 私有方法
#endregion
#region 生命周期函数
func _init() -> void:
	if Engine.is_editor_hint():
		resource_local_to_scene = true
	behavior_type = GameEnum.ContextBehaviorType.Pursue
func draw() -> void:
	super.draw()
#endregion
